package com.alpha.realife.advice;

import com.alpha.cexcep.realife.ExceptionResultRl;
import com.alpha.cexcep.realife.RlException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 拦截处理controller出现的异常
 * @author: Cheng
 */
@ControllerAdvice
public class BasicExceptionAdvice {

    @ExceptionHandler(RlException.class)
    public ResponseEntity<ExceptionResultRl> handleException(RlException e) {

        return ResponseEntity.status(e.getStatus()).body(new ExceptionResultRl(e));
    }

}
